# Maintainer: George Rawlinson <grawlinson@archlinux.org>

pkgname=ruby-unicode-emoji
_pkgname="${pkgname#ruby-}"
pkgver=3.3.1
pkgrel=1
pkgdesc='Provides Unicode Emoji data and regexes, incorporating the latest standards'
arch=('any')
url='https://github.com/janlelis/unicode-emoji'
license=('MIT')
depends=('ruby' 'ruby-unicode-version')
makedepends=('git')
checkdepends=('ruby-rake' 'ruby-minitest')
options=('!emptydirs')
_commit='3b64321c3e2bd81ff872429f2c68985b4edab25f'
source=("$pkgname::git+$url#commit=$_commit")
b2sums=('SKIP')

pkgver() {
  cd "$pkgname"

  git describe --tags | sed 's/^v//'
}

build() {
  cd "$pkgname"

  gem build "$_pkgname.gemspec"
}

check() {
  cd "$pkgname"

  rake spec
}

package() {
  cd "$pkgname"

  local _gemdir="$(gem env gemdir)"

  gem install \
    --local \
    --verbose \
    --ignore-dependencies \
    --no-user-install \
    --install-dir "$pkgdir/$_gemdir" \
    --bindir "$pkgdir/usr/bin" \
    "$_pkgname-$pkgver.gem"

  # delete cache
  rm -rf "$pkgdir/$_gemdir/cache"

  # license
  install -vd "$pkgdir/usr/share/licenses/$pkgname"
  ln -sf "$_gemdir/gems/$_pkgname-$pkgver/MIT-LICENSE.txt" "$pkgdir/usr/share/licenses/$pkgname"
}
